import React, { Component } from 'react';
import {
    View,
    Text,
    TouchableOpacity,
} from 'react-native';
import { positioncStyle as styles } from '../../../../../styles';
import sal from '../../../../util/sal';
import fmt from '../../../../util/fmtDateUtil';

export default class Positionc_a extends Component {
    // 初始化模拟数据
    constructor(props) {
        super(props);
    }
    render() {
        return (
            <TouchableOpacity
                style={styles.possevery}
                onPress={() => { this.goGet('Postionin', this.props.postions.postionId) }}
                activeOpacity={1}
            >
                <View style={styles.possevery1}>
                    <Text style={styles.possname}>{this.props.postions.postionName}</Text>
                    <Text style={styles.possmoney}>{sal(this.props.postions.postionMm, this.props.postions.postionYm)}</Text>
                </View>
                <View style={styles.possevery2}>
                    <View style={styles.posssmall}>
                        <Text style={styles.posstext}>{this.props.postions.postionSpace}</Text>
                        <Text style={styles.posstext}>{this.props.postions.postionExp}年经验</Text>
                        <Text style={styles.posstext}>{this.props.postions.postionEducation}</Text>
                    </View>

                    <Text style={styles.posstime}>{fmt(this.props.postions.publishTime, 'yyyy-MM-dd')}</Text>
                </View>
                <Text style={styles.possclassify}>{this.fieldName(this.props.fields, 3)}</Text>
            </TouchableOpacity>
        )
    }
    goGet(name, id) {
        this.props.navigation.navigate(name, { useId: id });
    }
    //领域
    fieldName(List, sl) {
        let arr = '';
        if (List != undefined) {
            let s = sl;
            let length = List.length
            if (length <= s) {
                s = length
            }
            for (let i = 0; i < s; i++) {
                arr += List[i].fieldName + '/';
            }
            if (arr.endsWith('/')) {
                arr = arr.substr(0, arr.length - 1);
            }
        }
        return arr;
    }
}